package com.stone.service;

import com.baomidou.mybatisplus.annotation.TableName;
import org.reflections.Reflections;
import org.springframework.stereotype.Service;

import java.util.Set;

/**
 * 扫描某包路径下的注解
 */
@Service
public class PackageScannerService {

    public void packageScan(String packageName) {
        //反射
        Reflections ref = new Reflections(packageName);

        // 获取扫描到的标记注解的集合
        Set<Class<?>> set = ref.getTypesAnnotatedWith(TableName.class);

        System.out.println("--------start-------------");
        for (Class<?> c : set) {
            // 循环获取标记的注解
            TableName annotation = c.getAnnotation(TableName.class);

            if (annotation != null) {
                // 打印注解中的内容
                System.out.println(annotation.value());
            }
        }
        System.out.println("--------over-------------");
        // dfssf
    }

    public static void main(String[] args) {

        // packageScan("com.stone.entity.po");
    }
}
